#ifndef _ICMPCLIENT_HPP_
#define _ICMPCLIENT_HPP_

#include "jhdefs.hpp"
#include "net/ICMPEventArgs.hpp"
#include "net/SocketAddress.hpp"
#include "net/IPAddress.hpp"
#include "event/basicevent.hpp"
using JHCPP::event::TBasicEvent;

#include <string>

NET_NAMESPACE_BEGIN

class CICMPClient
{
public:
	mutable TBasicEvent<CICMPEventArgs> pingBegin;
	mutable TBasicEvent<CICMPEventArgs> pingReply;
	mutable TBasicEvent<CICMPEventArgs> pingError;
	mutable TBasicEvent<CICMPEventArgs> pingEnd;

	explicit CICMPClient(CIPAddress::Family family);
	~CICMPClient();

	int ping(CSocketAddress& address, int repeat = 1) const;
	int ping(const std::string& address, int repeat = 1) const;

	static int ping(CSocketAddress& address, CIPAddress::Family family, int repeat = 1);
	static int pingIPv4(const std::string& address, int repeat = 1);

private:
	mutable CIPAddress::Family m_family;
};

NET_NAMESPACE_END

#endif
